package com.yuan.testeasyexcel.testbage;

import com.alibaba.excel.EasyExcel;
import org.junit.Test;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: test
 * @Description: TODO
 * @Author MrYuan
 * @Date: 2020/12/11 16:48
 * @Version 1.0
 */
public class test {
@Test
    public void write(){
    String fileName = "E:\\gitclone\\1\\new2"+"\\yuanquan"+".xlsx";
    EasyExcel.write(fileName, dog.class).sheet("模板").doWrite(data());
}
@Test
public void read(){
    String fileName ="E:\\gitclone\\1\\new2"+"\\yuanquan"+".xlsx";
    // 这里 需要指定读用哪个class去读，然后读取第一个sheet 文件流会自动关闭
    EasyExcel.read(fileName, dog.class, new DemoDataListener()).sheet().headRowNumber(2).doRead();
}
    public List<dog> data(){
        ArrayList<dog> dogs = new ArrayList<>();
        dogs.add(new dog("2"));
//        dogs.add(new dog(3,"wu"));
        return dogs;
    }
}